import importlib
from . import logger
from . import config

logger = logger.get_logger(__package__)

class Busy(BaseException):
    pass


class Processor:
    def put(self, connection, packet):
        raise NotImplementedError

    def get(self, connection):
        raise NotImplementedError


module_path, cls_name = config.request_processor["backend"].rsplit(".", 1)
module = importlib.import_module(module_path)
_Processor = getattr(module, cls_name)
if not issubclass(_Processor, Processor):
    raise TypeError(_Processor)

logger.info("Loaded processor backend ... ... [%s]" % config.request_processor['backend'])
processor = _Processor(**config.request_processor["arguments"])
